package model;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * Meeting info interface
 */
public class MeetingInfo implements Serializable
{
    private static final long serialVersionUID = 1757873432597873219L;

    public static int MEETING_SUBJECT_CHANGED = 0;
    public static int MEETING_MESSAGE_CHANGED = 1;
    public static int MEETING_START_TIME_CHANGED = 2;
    public static int MEETING_END_TIME_CHANGED = 3;
    public static int MEETING_LOCATION_CHANGED = 4;
    public static int MEETING_ID = 5;
    public static int USER = 6;
  
    public static String MEETING_ACCEPTED = "Accepted";
    public static String MEETING_REJECTED = "Rejected";
    public static String MEETING_NO_ACTION = "No Action";
    public static String MEETING_CANCELLED = "Cancelled";

    public String originalSubject = "";
    public String originalMessage = "";
    public String originalStartTime = "";
    public String originalEndiTime = "";
    public String origianlPlace = "";
    public List<String> receivers = new LinkedList<String>();
    public String sender = "";
    public String meetingID = "";
    public Map<Integer,String>  meetingParticipantData = new LinkedHashMap<Integer,String>();
    
    /**
     * Constructor
     * @param meetingID meeting id
     */
    public MeetingInfo(String meetingID)
    {
       this.meetingID = meetingID;

    }
    
    /**
     * Default Constructor
     */
    public MeetingInfo()
    {

    }
    
    /**
     * set subject
     * @param originalSubject subject of the email
     */
    public void setOriginalSubject(String originalSubject)
    {
        this.originalSubject = originalSubject;
    }

    /**
     * set message
     * @param originalMessage message of the email
     */
    public void setOriginalMessage(String originalMessage)
    {
        this.originalMessage = originalMessage;
    }

    /**
     * set meeting start time
     * @param originalStartTime meeting start time
     */
    public void setOriginalStartTime(String originalStartTime)
    {
        this.originalStartTime = originalStartTime;
    }

    /**
     * set meeting end time
     * @param originalEndiTime meeting end time
     */
    public void setOriginalEndiTime(String originalEndiTime)
    {
        this.originalEndiTime = originalEndiTime;
    }

    /**
     * set meeting place
     * @param origianlPlace meeting place
     */
    public void setOrigianlPlace(String origianlPlace)
    {
        this.origianlPlace = origianlPlace;
    }

    /**
     * set receiver(s) of the meeting email
     * @param receivers list of meeting email receiver(s)
     */
    public void setReceivers(List<String> receivers)
    {
        this.receivers = receivers;
        for(String user : this.receivers)
        {
            this.meetingParticipantData.put(user.hashCode(), MEETING_NO_ACTION);
        }
    }
    
    /**
     * update the meeting status
     * @param user meeting participant
     * @param status meeting status of the user
     */
    public void updateStatus(String user, String status)
    {
          this.meetingParticipantData.remove(user.hashCode());
          this.meetingParticipantData.put(user.hashCode(), status);
    }

    /**
     * set the meeting request sender
     * @param sender the sender of the meeting request
     */
    public void setSender(String sender)
    {
        this.sender = sender;
        this.meetingParticipantData.put(sender.hashCode(), MEETING_ACCEPTED);
    }
}
